﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bxas.Utility.StringOperations
{
    public class PasswordGenerator
    {
        private static int random_rumber(int min, int max)
        {
            Random random = new Random();
            return random.Next(min, max);
        }

        private static string random_string(int size, bool lowerCase)
        {
            StringBuilder builder = new StringBuilder();
            Random random = new Random();
            char ch;
            for (int i = 0; i < size; i++)
            {
                ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
                builder.Append(ch);
            }

            string value = "";

            foreach (var item in builder.ToString())
            {
                if (item == 'ı') value += "i";
                else if (item == 'İ') value += "I";
                else if (item == 'ğ') value += "g";
                else if (item == 'Ğ') value += "G";
                else if (item == 'ü') value += "u";
                else if (item == 'Ü') value += "U";
                else if (item == 'ş') value += "s";
                else if (item == 'Ş') value += "S";
                else if (item == 'ö') value += "O";
                else if (item == 'Ö') value += "O";
                else if (item == 'ç') value += "c";
                else if (item == 'Ç') value += "C";
                else value += item.ToString();
            }

            if (lowerCase)
                return value.ToLower();
            return value.ToString();
        }

        public static string get_password()
        {
            StringBuilder builder = new StringBuilder();
            builder.Append(random_string(4, true));
            builder.Append(random_rumber(1000, 9999));
            builder.Append(random_string(2, false));
            return builder.ToString();
        }
    }
}